package com.zwk.gulimall.gateway;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.core.annotation.Order;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

@Component
@Order(1)
public class MyFilter1 implements GatewayFilter {
//    @Value("${spring.cloud.gateway.routes[3].filters[0]}")
//    private String str;
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        ServerHttpRequest request = exchange.getRequest();
        System.out.println(request.getPath());
        //请求前：/captcha.jpg  ，url：http://localhost:10010/captcha.jpg?sdaa
        //请求后：/renren-fast/captcha.jpg/renren-fast/     ,url:http://localhost:10010/renren-fast/captcha.jpg/renren-fast/?sdaa
        //  /?(?<segment>.*),/renren-fast/$\{segment}
        //不带问号：/renren-fast/captcha.jpg     url:http://localhost:10010/renren-fast/captcha.jpg?sdaa
        //不带斜杆
        //  http://localhost:10010/renren-fast//captcha.jpg/renren-fast/?sdaa
        return chain.filter(exchange);
//        return null;
    }
}
